// Copyright (c) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.
#pragma once

namespace Weathr
{
    public enum class LogMessageKind
    {
        Info,
        Warning,
        Error,
        AsyncAction,
    };

    [Windows::UI::Xaml::Data::Bindable]
    [Windows::Foundation::Metadata::WebHostHidden]
    public ref class LogMessage sealed
    {
    internal:
        LogMessage(LogMessageKind kind, Platform::String^ text) : m_kind(kind), m_text(text)
        {
        }

    public:
        property LogMessageKind Kind
        {
            LogMessageKind get()
            {
                return m_kind;
            }
        }
        property Platform::String^ Text
        {
            Platform::String^ get()
            {
                return m_text;
            }
        }

    private:
        LogMessageKind m_kind;
        Platform::String^ m_text;
    };

    delegate void LogMessageAddedHandler(Platform::Object^ sender, LogMessage^ message);

    // Provides a basic way to log messages.
    ref class Logger sealed
    {
    internal:
        static void LogInfo(Platform::Object^ sender, Platform::String^ text);
        static void LogWarning(Platform::Object^ sender, Platform::String^ text);
        static void LogError(Platform::Object^ sender, Platform::String^ text);

        static concurrency::task_completion_event<bool> LogAsyncAction(Platform::Object^ sender, Platform::String^ text);

        static event LogMessageAddedHandler^ LogMessageAdded;

    private:
        Logger(); // deleted and defaulted functions are not supported in WinRT classes
    };
}